﻿module CodeCamp00
{
  export Event;
  export Events;
    
  // Event 
  
  type Event
  {
    Id : Integer32 => AutoNumber();
    DisplayName : Text where value.Count <= 128;
    ShortName : Text where value.Count <= 32;
  }
    
  Events : { Event* } where
    identity Id,
    unique DisplayName,
    unique ShortName;
    
  Events
  {
    { DisplayName => "Portland Code Camp 2010", ShortName => "2010" }
  }
    
  // Presenter

  type Presenter
  {
    Id : Integer32 => AutoNumber();
    EventId : Event where value in Events;
    UserIdentityName: Text where value.Count <= 128; // username from ASP.NET membership provider
    FirstName : Text where value.Count <= 128;
    LastName : Text where value.Count <= 128;
    TwitterName : (Text where value.Count <= 128)?;
    EmailAddress : Text where value.Count <= 128;
    Biography : Text where value.Count <= 4000;
  }

  Presenters : { Presenter* } where 
    identity Id, 
    unique( UserIdentityName, EventId ), 
    unique( EmailAddress, EventId );

  // Session

  type Session
  {
    Id : Integer32 => AutoNumber();
    EventId : Event where value in Events;
    PresenterId : Presenter where value in Presenters;
    Title : Text where value.Count <= 128;
    Description : Text where value.Count <= 4000;
  }
    
  Sessions : { Session* } where identity Id;
    
  // Sponsor
    
  type Sponsor
  {
        Id : Integer32 => AutoNumber();
        EventId : Event where value in Events;
        Name : Text where value.Count <= 128;
        Url : Text where value.Count <= 1024;
        ImageUrl : Text where value.Count <= 1024;
        ImageHeight : Integer32;
        ImageWidth : Integer32;
  }
    
  Sponsors : { Sponsor* } where
    identity Id,
    unique( Name, EventId );
    
  Sponsors
  {
    {
      EventId => Events(1), 
      Name => "Microsoft", 
      Url => "http://www.microsoft.com", 
      ImageUrl => "http://www.microsoft.com/presspass/images/gallery/logos/web/mslogo-1.jpg",
      ImageWidth => 500,
      ImageHeight => 83
    }
  }
}
